# This file is part of the Spring engine (GPL v2 or later), see LICENSE.html

# - Find LaTeX.
# Find the native LaTeX binary including pdflatex, xelatex.
#
#  PDFLATEX_BIN    - will be set to the pdflatex executable (eg. pdflatex.exe)
#  XELATEX_BIN     - will be set to the xelatex executable (eg. xelatex.exe)
#  PDFLATEX_FOUND    - TRUE if pdflatex was found
#  XELATEX_FOUND    - TRUE if xelatex was found

Include(FindPackageHandleStandardArgs)

If(PDFLATEX_BIN)
  # Already in cache, be silent
  Set(PDFLATEX_FIND_QUIETLY TRUE)
EndIf (PDFLATEX_BIN)

If(XELATEX_BIN)
  # Already in cache, be silent
  Set(XELATEX_FIND_QUIETLY TRUE)
EndIf (XELATEX_BIN)

find_program(PDFLATEX_BIN
    NAMES pdflatex
    DOC "pdflatex executable"
)

find_program(XELATEX_BIN
    NAMES xelatex
    DOC "xelatex executable"
)

# handle the QUIETLY and REQUIRED arguments and set PDFLATEX_FOUND to TRUE if
# all listed variables are TRUE
FIND_PACKAGE_HANDLE_STANDARD_ARGS(pdflatex DEFAULT_MSG PDFLATEX_BIN)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(xelatex DEFAULT_MSG XELATEX_BIN)
